< previous page page_226 next page >

Page 226
You can create a new procedure in the Code window by following these steps:
1. Open the code for Form1 by clicking the View Code button.
2. Type the keyword Sub, followed by a space.
3. Type the name of your new procedureFirstProc in this example.
4. Press the Enter key to create the procedure.
When you press Enter, three things happen: a set of parentheses is added at the end of the Sub statement, an End Sub statement is placed in the Code window, and the current object in the Procedure drop-down list of the code editing window becomes your new procedure name. Figure 11.2 shows these changes for a procedure named FirstProc.
0226-01.jpg
Figure 11.2
The End Sub statement is automatically added when you define a new procedure.
You are now ready to enter any commands that you want to run when the procedure is called.
The full syntax of a Sub procedure includes the Sub statement, the End Sub statement, and the procedure commands:
[Public | Private] [Static] Sub procname([arguments])
statements_to_be_run
End Sub
The Public, Private, and Static keywords in the Sub statement are optional and affect the locations from which the procedure might be called. These keywords indicate the scope of the procedure in the same way that they indicate the scope of a variable.
sarrow.gifSee "Determining Where a Variable Can Be Used," p. 166
The other method of creating a procedure is to use the Add Procedure dialog box (see Figure 11.3). You access this dialog box by choosing Tools, Add Procedure.

 
< previous page page_226 next page >